﻿using ICSharpCode.AvalonEdit.Highlighting;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace AESUtil.Converters
{
    internal class TextLengthToHighlightingConverter: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string text = value as string;
            int length = text?.Length ?? 0;

            if (length > 20)
            {
                return null; // 关闭语法高亮
            }
            else
            {
                // 返回 JSON 语法高亮（需要确保已注册）
                return HighlightingManager.Instance.GetDefinition("Json");
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
